package com.farewell.blog.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.farewell.blog.entity.QueryBean;
import com.farewell.blog.pojo.Blog;
import com.farewell.blog.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author Farewell
 * @date 2021/2/15
 */
@Controller
public class FootController {
    @Autowired
    private BlogService blogService;

    @GetMapping("/footer/newblog")
    public String footer(Model model) {
        QueryBean queryBean = new QueryBean(1, 5, null);
        Page<Blog> blogPage = blogService.listBlog(queryBean);
        model.addAttribute("newblogs", blogPage.getRecords());
        return "_fragments :: newblogList";
    }
}
